<template>
  <el-form :inline="true" :disabled="disabled">
    <el-form-item label="一级分类">
      <el-select
        v-model="categoryStore.category1Id"
        placeholder="请选择"
        @change="changeCategory1Id"
      >
        <el-option
          v-for="item in categoryStore.category1List"
          :value="item.id"
          :key="item.id"
          :label="item.name"
        >
        </el-option>
      </el-select>
    </el-form-item>
    <el-form-item label="二级分类">
      <el-select
        v-model="categoryStore.category2Id"
        placeholder="请选择"
        @change="changeCategory2Id"
      >
        <el-option
          v-for="item in categoryStore.category2List"
          :value="item.id"
          :key="item.id"
          :label="item.name"
        >
        </el-option>
      </el-select>
    </el-form-item>
    <el-form-item label="三级分类">
      <el-select v-model="categoryStore.category3Id" placeholder="请选择">
        <el-option
          v-for="item in categoryStore.category3List"
          :value="item.id"
          :key="item.id"
          :label="item.name"
        >
        </el-option>
      </el-select>
    </el-form-item>
  </el-form>
</template>

<script setup lang="ts">
import { onMounted } from "vue";
import { useCategoryStore } from "@/stores/category";

defineProps<{
  disabled: boolean;
}>();
const categoryStore = useCategoryStore();
onMounted(() => {
  categoryStore.getCategory1List();
});
const changeCategory1Id = () => {
  categoryStore.getCategory2List();
};
const changeCategory2Id = () => {
  categoryStore.getCategory3List();
};
</script>

<style scoped lang="css"></style>
